import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  scrollBehavior (to, from, savedPosition) {
    // return 期望滚动到哪个的位置
    // vue2.0  x  y  控制
    // vue3.0  left  top 控制
	return { left: 0, top: 0 }  },
  routes: [
    {
      path:"/",
      name:"layout",
      component:()=>import ('@/views/Layout.vue'),
      children:[{
        path:"/",
        name:"所有文章",
        component:()=>import ('@/views/forum/ArticleList.vue'),
      },{
        path:"/tags",///post/articleId
        name:"标签页面",
        component:()=>import ('@/views/Tags.vue'),
      },{
        path:"/search",///post/articleId
        name:"搜索页面",
        component:()=>import ('@/views/Search.vue'),
      },
      {
        path:"/detail",///post/articleId
        name:"详情页面",
        component:()=>import ('@/views/forum/Detail.vue'),
      },
      {
        path:"/my",///post/articleId
        name:"我的页面",
        component:()=>import ('@/views/forum/My.vue'),
      },
      {
        path:"/other",///post/articleId
        name:"其他",
        component:()=>import ('@/views/forum/Other.vue'),
      },
      {
        path:"/notice",///post/articleId
        name:"公告",
        component:()=>import ('@/views/forum/Notice.vue'),
      },
    ]
     
    },
    {
      path:"/admin",///post/articleId
      name:"后台管理",
      component:()=>import ('@/views/HomeView.vue'),
      children:[{
        name:'仪表盘',
        path:'/admin/dashboard',
        component: () => import('../views/dashboard/dashboard.vue')
      },
      {
        name:'管理员管理',
        path:'/admin/managers',
        component: () => import('../views/managers/managers.vue')
      },
      {
        name:'文章管理',
        path:'/admin/articles',
        component: () => import('../views/articles/articles.vue')
      },
      {
        name:'评论管理',
        path:'/admin/comments',
        component: () => import('../views/comments/comments.vue')
      },
      {
        name:'关注管理',
        path:'/admin/follow',
        component: () => import('../views/follow/follow.vue')
      },
      {
        name:'个人资料',
        path:'/admin/profile',
        component: () => import('../views/profile/profile.vue')
      },
      {
        name:'标签管理',
        path:'/admin/tags',
        component: () => import('../views/tags/tags.vue')
      },
      {
        name:'用户管理',
        path:'/admin/users',
        component: () => import('../views/users/users.vue')
      },
      {
        name:'公告管理',
        path:'/admin/notices',
        component: () => import('../views/notices/notices.vue')
      },
      //用户路径
      {
        name:'用户仪表盘',
        path:'/admin/user/dashboard',
        component: () => import('../views/dashboard/userDashboard.vue')
      },
      {
        name:'用户文章管理',
        path:'/admin/user/articles',
        component: () => import('../views/articles/userArticles.vue')
      },
      {
        name:'用户评论管理',
        path:'/admin/user/comments',
        component: () => import('../views/comments/userComments.vue')
      }]
    }
  ]
})

export default router
